import java.util.Arrays;

public class Test {

    public static Integer func(int a) {
        return Integer.valueOf(a);
    }
    public static int search1(int[] arr, int target) {
        //找到中间元素，判断和右边的数字哪个大，如果是中间数字小于右边数字，说明最小值在左边
        //，如果中间数字大于右边数字，说明最小值在右边
        int left = 0;
        int right = arr.length - 1;
        int mid = (left + right) / 2;
        //找到一个范围，对这个范围进行二分查找
        //找到最小值才能二分查找！
        if (arr[mid]==target) {
            return mid;
        }
        if (arr[mid]<arr[right]) {
            //中间右边是有序的
            //判断是在左边还是右边
            if (arr[mid]<target) {
                //在右边有序
                left=mid+1;
                while (left<right) {
                    mid = (left + right) / 2;
                    if (arr[mid]<target) {
                        left=mid+1;
                    } else if (arr[mid]>target){
                        right=mid-1;
                    } else {
                        return mid;
                    }
                }
            }else {
                //在左边无序

            }
        } else {
            //中间左边是有序的

        }
        return -1;
    }
    public static int search(int[] arr, int target) {
        for (int i = 0; i <arr.length ; i++) {
            if (arr[i]==target) {
                return i;
            }
        }
        return  -1;
    }

    public  static int missingNumber(int[] nums) {

        int num=0;
        for (int i = 0; i <nums.length ; i++) {
            num+=nums[i];
        }
        int num1=0;
        for (int i = 0; i < nums.length+1; i++) {
            num1+=nums[0]+i;
        }
        return num1-num;
    }
    public static int removeElement(int[] nums, int val) {
        int left=0;
        int right=nums.length-1;
        int count=0;
        while (left<right) {
            while (nums[left] != val && left < right) {
                left++;
            }
            while (nums[right] == val && left < right) {
                right--;
            }
            if (left < right) {
                int tmp = nums[left];
                nums[left] = nums[right];
                nums[right] = tmp;
            }
        }
        for (int i = 0; i <nums.length ; i++) {
            if (nums[i]==val) {
            count++;
            }
        }
        return nums.length-count;
    }

    public static void main(String[] args) {
        int []array={4,5};
        int[]array2={1,2,3,5};
        System.out.println(missingNumber(array2));

        //        System.out.println(removeElement(array, 4));
//       System.out.println(Arrays.toString(array));

    }
    public static void main2(String[] args) {
        Integer a=10;
        int val1=a.intValue();
        int val2=a;
        System.out.println(val1);
        System.out.println(val2);
        Integer b=func(20);
        System.out.println(b);
        String name="胖胖1";
        Boolean p=new Boolean(name);
        System.out.println(p);
    }
    public static void main1(String[] args) {

        int a=10;
        Integer val= a;
        Integer val1=new Integer(a);
        Integer val2=Integer.valueOf(a);
        System.out.println(val);
        System.out.println(val1);
        System.out.println(val2);
    }
}
